const {
    Schema,
    model
} = require('mongoose');
const moment = require("moment")


const usersSchema = new Schema({
    username: String,
    password: String,
    money: {
        type: Number,
        default: 0,
    },
    img: String,
    role: {
        type: String,
        default: '0',
    },
    checkStatus: {
        type: String,
        default: 'no', //用户注册后未经实名认证，不能开始租车，默认值为no，
    },
    phone: String,
    address: String,
    latitude: String,//经度
    longitude: String,//纬度
    name: String,//身份证姓名
    idCard: String,//身份证号
    time: {
        type: String,//车辆上架时间
        default: moment().format('YYYY年MM月DD日')
    },//用户注册的时间
    favorite: [{
        type: Schema.Types.ObjectId,
        ref: 'Cars'
    }],//收藏列表
    praiseCount: {
        type: Number,
        default: 0,
    },//好评数
    badCount: {
        type: Number,
        default: 0,
    }//差评数
}, {
    versionKey: false
});

const Users = model('Users', usersSchema, 'users');
module.exports.Users = Users;